package com.yangwp.jie.controller;

import com.yangwp.jie.model.JieArticle;
import com.yangwp.jie.service.JieArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/jie")
public class MainController {

    @Autowired
    private JieArticleService jieArticleService;

    @RequestMapping("")
    public String main(ModelMap modelMap){
        List<JieArticle> articleList = jieArticleService.getContents();
        if(!CollectionUtils.isEmpty(articleList)){
            modelMap.put("articles", articleList);
        }
        return "/main/index.ftl";
    }


}
